package bean;
import java.sql.*;
import java.util.ArrayList;

import bean.DBConnection;
import bean.Caipin;

public class CaipinDAO {public static ArrayList retrieveAll() {
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	conn = DBConnection.getConnection();
	ArrayList msg = new ArrayList();
	String sql = "select * from caipin where id=1 or id=2 or id=3";
	
	try {
		pstmt = conn.prepareStatement(sql);
		rs = pstmt.executeQuery();
		while(rs.next()){   //光标往下移一位 
			Caipin caipin = new Caipin();
			caipin.setId(rs.getInt("id"));
			caipin.setName(rs.getString("name"));
			caipin.setMiaoshu(rs.getString("miaoshu"));
			caipin.setPrice(rs.getFloat("price"));
			caipin.setVipprice(rs.getFloat("vipprice"));
			msg.add(caipin);
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} finally {
		DBConnection.closeDB(conn, pstmt, rs);
	}
	return msg;
}
}



